package cn.haohaowo;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

/**
 * Created by luwancai on 18/5/30.
 * DESC:
 */
@Slf4j
@Component
public class Follower2Listener {

    @Autowired
    @Qualifier("haoShopKafkaTemplate")
    private KafkaTemplate kafkaTemplate;

    @KafkaListener(topics = "stockfollower")
    public void doRunJob(ConsumerRecord record) {
        log.info("Is follower2, send: {}", record.value());

        kafkaTemplate.send("stockleader", "Follower2 is success!");
    }

}
